#include "plugin.h"
#include <extensions/context.h>

namespace Optra {

namespace Extensions{


QString Plugin::ExtNativeExtension		= "one";
QString Plugin::ExtNativeApplication		= "ona";

QString Plugin::ExtScriptExtension		= "ose";
QString Plugin::ExtScriptApplication		= "osa";

QString Plugin::ExtDeclarativeExtension		= "ode";
QString Plugin::ExtDeclarativeApplication	= "oda";

class PluginPrivate{
public:
    PluginPrivate() :
        valid(true)

    {}

    ~PluginPrivate()
    {

    }

    Plugin::Type type;
    Plugin::Area area;
    bool valid;
    QString errorString;
    QString name;
    ContextPtr context;
};

Plugin::Plugin():
O_PRIVATE_CREATE(Plugin)
{

}

Plugin::Plugin(Type type, const ContextPtr& ctx, Opl::Core::EntityObject *parent) :
    Opl::Core::EntityObject(parent), O_PRIVATE_CREATE(Plugin)
{
    Setup(type, ctx);
}

Plugin::~Plugin()
{
    O_PRIVATE_DELETE;
}

void Plugin::Setup(Type type, const ContextPtr& ctx)
{
    O_D(Plugin);
    d->type = type;
    d->context = ctx;
}

Plugin::Type Plugin::type()const
{
    O_C(Plugin);
    return d->type;
}

bool Plugin::valid()
{
    O_D(Plugin);
    return d->valid;
}

void Plugin::setValid(bool state)
{
    O_D(Plugin);
    d->valid = state;
}

const QString& Plugin::errorString()const
{
    O_C(Plugin);
    return d->errorString;
}

void Plugin::setErrorString(const QString& error)
{
    O_D(Plugin);
    d->errorString = error;
}

const QString& Plugin::name()const
{
    O_D(const Plugin);
    return d->name;
}

void Plugin::setName(const QString& value)
{
    O_D(Plugin);
    d->name = value;
}

Plugin::Area Plugin::area()const
{
    O_C(Plugin);
    return d->area;
}

void Plugin::setContext(const ContextPtr& ctx)
{
    O_D(Plugin);
    d->context = ctx;
}

const ContextPtr& Plugin::context()const
{
    O_C(Plugin);
    return d->context;
}

void Plugin::setArea(Area area)
{
    O_D(Plugin);
    d->area = area;
}

void Plugin::Start()
{
    //O_D(Plugin);

}

QString Plugin::toString()
{
    O_D(Plugin);
    return EntityObject::toString();
}

}}
